package org.sevaapp.controller;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import org.sevaapp.domain.Applicant;
import org.sevaapp.domain.Lab;
import org.sevaapp.domain.Referral;
import org.sevaapp.service.ReferralProcessLabService;
import org.sevaapp.service.ReferralProcessPhyService;

/**
 *  THIS IS A CODE GENERATED FILE. DO NOT EDIT.
 */

public abstract class BaseReferralProcessPhyController {

	private static final Log log = LogFactory.getLog(BaseReferralProcessPhyController.class);

	@Autowired
	private Referral domainObj;

	@Autowired
	private ReferralProcessPhyService serviceObj;

	/**
	 * Validation method in the controller layer. Every controller should implement this method
	 * to manage the data input validation in a standard and consistent way.
	 */
	public abstract boolean validate(Referral inputData);

	/**
	 * Controller method for displaying the screen the first time
	 */
	@RequestMapping("/displayReferralProcessPhy.do")
	public String displayPhy(@ModelAttribute("referral") Referral inputData) {
		log.debug("displayPhy() method called.");
		log.debug("Domain Object Data:" + inputData.toString());

		return "referralProcessPhy";
	}

	/**
	 * Controller method for adding a new record
	 */
	@RequestMapping("/addReferralProcessPhy.do")
	public String addNewPhy(@ModelAttribute("referral") Referral inputData) {
		log.debug("addNewPhy() method called.");
		log.debug("Domain Object Data:" + inputData.toString());

		// Call validate method
		boolean isValidData = validate(inputData);
		log.debug("isValidData=" + isValidData);
		if (isValidData) {
			if (inputData.getId() == null) {
				// New record, call add method
				serviceObj.addNewReferral(inputData);
			} else {
				// Existing record, call edit method
				serviceObj.updateReferral(inputData);
			}
			return "referralProcessPhy";
		}
		return "referralProcessPhy";
	}

//	/**
//	 * Controller method for editing an existing record
//	 */
//	@RequestMapping("/editLab.do")
//	public String editLab(@ModelAttribute("lab") Lab inputData) {
//		log.debug("editLab() method called.");
//		log.debug("Domain Object Data:" + inputData.toString());
//
//		// Call validate method
//		boolean isValidData = validate(inputData);
//		log.debug("isValidData=" + isValidData);
//		if (isValidData) {
//			domainObj.update(inputData);
//			return "lab";
//		}
//		return "lab";
//	}
//
//	/**
//	 * Controller method for displaying an existing record
//	 */
//	@RequestMapping("/loadLab.do")
//	public String loadLab(@ModelAttribute("lab") Lab inputData) {
//		log.debug("loadLab() method called.");
//		log.debug("Domain Object Data:" + inputData.toString());
//
//		// Call validate method
//		boolean isValidData = validate(inputData);
//		log.debug("isValidData=" + isValidData);
//		if (isValidData) {
//			Integer id = inputData.getId();
//			domainObj.load(id);
//			return "lab";
//		}
//		return "lab";
//	}
}
